<template>
  <el-upload
    v-model:file-list="fileList"
    class="upload-demo"
    action="https://api.user.grazlink.com/index.php/api/upload"
    :on-change="handleChange"
    :on-success="trre"
  >
    <el-button type="primary">点击上传</el-button>
    <template #tip>
      <div class="el-upload__tip"> jpg/png 大小小于500kb </div>
    </template>
  </el-upload>
  <button @click="hhh">获取</button>
</template>
<script lang="ts" setup>
import { ref } from 'vue'

import type { UploadProps, UploadUserFile } from 'element-plus'

import axios from 'axios'

const fileList = ref<UploadUserFile[]>([])

const hhh = () => {
  axios({
    method: 'get',
    url: 'https://api.user.grazlink.com/index.php/api/upload'
  }).then((res) => {
    console.log(res)
  })
}
function trre(response) {
  if (response.code == '200') {
    // console.log(response.data)
  }
}
const handleChange: UploadProps['onChange'] = (uploadFile, uploadFiles) => {
  console.log(uploadFile)
  console.log(uploadFiles)

  fileList.value = fileList.value.slice(-3)
}
</script>
